//mongodb node的驱动程序
const mongoose = require("mongoose");
//引入 执行model
require("../db/model/navs");
//初始化数据(生成商品大类导航)
const navs = [
  { name: "乳品面包" },
  { name: "酒类饮品" },
  { name: "饮料/水" },
  { name: "休闲零食" },
  { name: "米面粮油" },
  { name: "糖果饼干" },
  { name: "方便速食" },
  { name: "营养冲调" },
  { name: "个人护理" },
  { name: "日用百货" },
  { name: "纺织用品" },
];
//建立连接
mongoose.connect(
  "mongodb://tangzhenhua:Lovo123456@182.92.214.223:8084/maiwenjie-project",
  {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    auth: { authSource: "admin" },
  },
  async () => {
    const navsModel = mongoose.model("navs"); //创建model
    const data = await navsModel.create(navs); //调用create方法
    console.log(data);
  }
);
